﻿<!DOCTYPE html>
<html>

	<head>

		<script type="text/javascript" src="#(ctx)/lambkit/assets/jquery.min.js"></script>
		<script type="text/javascript">
			$(function() {
				$(".list_table").colResizable({
					liveDrag: true,
					gripInnerHtml: "<div class='grip'></div>",
					draggingClass: "dragging",
					minWidth: 30
				});

			});
		</script>
	</head>

	<body>
		<div class="container">
			<div id="forms" class="main_top">
				<div class="box">
					<div class="box_border">
						<div class="box_top"><b class="pl15">上传</b></div>
						<div class="box_center">
							<form id="myform" method="post">

								<table class="form_table pt15 pb15" width="100%" border="0" cellpadding="0" cellspacing="0">
									<tr>
										<td class="td_right">名称：</td>
										<td class="">
											<input type="text" name="id" id="name" class="input-text lh30" size="40">
										</td>
										<td class="">${msg_id!}</td>
									</tr>
									<tr>
										<td class="td_right">地址：</td>
										<td class="">
											<input type="text" name="path" id="path" class="input-text lh30" size="40">
										</td>
										<td class="">${msg_path!}</td>
									</tr>
									<tr>
										<td class="td_right">文件：</td>
										<td class="">
											<input type="file" name="Filedata" class="input-text lh30" size="40">
										</td>
										<td class="">${msg_Filedata!}</td>
									</tr>
									<tr>
										<td class="td_right">&nbsp;</td>
										<td class="">
											<input type="button" name="button" class="btn btn82 btn_save2" value="保存">
										</td>
									</tr>
								</table>
							</form>
						</div>
					</div>
				</div>
			</div>
		</div>
		<script type="text/javascript">
			$().ready(function() {

				$(".btn_save2").click(function() {

					// 文件元素
					var file = document.querySelector('[type=file]');
					var name = document.getElementById("name").value;
					var path = document.getElementById("path").value;

					// 通过FormData将文件转成二进制数据
					var formData = new FormData();
					// 将文件转二进制
					formData.append('Filedata', file.files[0]);
					formData.append('target', path);
					formData.append('id', name);

					$.ajax({
						url: '${adminpage!' / admin '}/filemgr/upload',
						type: 'POST',
						data: formData, // 上传formdata封装的数据
						dataType: 'JSON',
						cache: false, // 不缓存
						processData: false, // jQuery不要去处理发送的数据
						contentType: false, // jQuery不要去设置Content-Type请求头
						success: function(data) { //成功回调
							if(data) {
								alert("保存成功！");
								location.reload();
							} else {
								alert("保存失败！");
							}
						}
					});
				});
			});
		</script>
	</body>

</html>